package com.Tokiu.web.response;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * Response重定向
 * 内部外部都可以转发
 */
@WebServlet("/resp1")
public class ReponseDemo1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("resp1....");
//        //设置响应状态码
//        response.setStatus(302);
//        //设置响应头 location
//        response.setHeader("Location","resp2");


        response.sendRedirect("resp2");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
